<template>
	<view class="classlist">
		<view class="content">
			<navigator :url="'../preview/preview?id='+item._id" class="item" v-for="item in classsList" :key="item._id">
				<image :src="item.smallPicurl" mode="aspectFill"></image>
			</navigator>
		</view>
	</view>
</template>

<script setup>
	import {
		globalVariable
	} from '../All.js'
	import {
		ref
	} from 'vue';

	import {
		onLoad,
		onReachBottom
	} from '@dcloudio/uni-app'

	var goPreview = () => {
		uni.navigateTo({
			url: '../preview/preview'
		})
	}

	var queryParams = {
		pageNum: 1
	};
	onLoad((e) => {
		var {
			id = null, name = null
		} = e; // 解构e获取id
		queryParams.classid = id
		// console.log(id, name);
		uni.setNavigationBarTitle({
			title: name
		})

		getClassLIst();
	})


	onReachBottom(() => {
		queryParams.pageNum++
		getClassLIst()
	})




	var classsList = ref([]);
	// 分类列表点击进入的壁纸列表
	var getClassLIst = async () => {
		var res = await uni.request({
			url: globalVariable().url + 'wallList',
			header: {
				"access-key": globalVariable().accessKey
			},
			data: {
				classid: queryParams.classid,
				pageNum: queryParams.pageNum
			}
		})
		// console.log(res);
		if (res.data.errCode === 0) {
			// 查询成功
			classsList.value = [...classsList.value, ...res.data.data];
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		display: grid;
		gap: 5rpx;
		grid-template-columns: repeat(3, 1fr);
		padding: 5rpx;

		.item {
			height: 440rpx;

			image {
				width: 100%;
				height: 100%;
				display: block;
			}
		}
	}
</style>